
import { _decorator, Component, Node, find, Label } from 'cc';
import { PlayerControl } from './PlayerControl';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = Score
 * DateTime = Thu Dec 09 2021 13:35:28 GMT+0800 (中国标准时间)
 * Author = huangsz
 * FileBasename = Score.ts
 * FileBasenameNoExtension = Score
 * URL = db://assets/scripts/Score.ts
 * ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
 *
 */

@ccclass('ScoreControl')
export class ScoreControl extends Component {

    start() {
        
    }

    update(deltaTime: number) {
        this.updateScore()
    }

    updateScore() {
        const player = find("Canvas/Player").getComponent(PlayerControl)
        if (player.score !== 0) {
            const theLabel = this.node.getComponent(Label)
            theLabel.string = `共击落 ${player.score} 架敌机`
        }
    }
}